finp$="picture.png"

' converts a 128x48 4c picture into a 'pmode1:screen1,0' binary file - chr 4x8 mode

fout1$=finp$+".zxb"
setdisplay(128,48,32,1):paper(8^8-1):ink(0):pen(0):cls
loadimage(finp$,1):pasteicon(0,0,1)

open fout1$ for output as #1

print #1,"asm"

for y1=0 to 7
  for x1=0 to 31
    txou1$="  defb "
    for y2=0 to 5
      y=(y1*6)+y2
      btv=0:btt=0
      for x2=3 to 0 step -1
        btv=btv*4
        u=point(x1*4+(3-x2),y)
        b=u mod 256: u=int(u/256)
        g=u mod 256: u=int(u/256)
        r=u mod 256: u=int(u/256)
        btt=0
        if r>128 then:btt=1:end if
        if g<128 then:btt=2:end if
        if r>128 and g<128 then:btt=3:end if
        btv=btv+btt
        next
      txou1$=txou1$+"0"+ucase$(right$("00"+hex$(btv),2))+"h"
      if y2<7 then:txou1$=txou1$+",":end if
      next
    print #1,txou1$

    next
  next

print #1,"end asm"

close #1

'waitkey

